package com.PQLoad
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;

	public class ImgLoader extends Load
	{
		public var bmd:BitmapData;
		public function ImgLoader(_url:String,param:Object=null)
		{
			load=new Loader();
			super(_url,param);
			urlload.dataFormat = URLLoaderDataFormat.BINARY;
			urlload.load(new URLRequest(url));
			type=0;
		}
		/**本方法需要等资源加载完毕后方可调用**/
		public function copy():DisplayObject{
			return new Bitmap(bmd);
		}
		override protected function loaded(e:Event):void{
			load.contentLoaderInfo.addEventListener(Event.COMPLETE,byteloaded);
			load.loadBytes(urlload.data);
			removeListen();
		}
		private function byteloaded(e:Event):void{
			bmd=e.target.content.bitmapData;
			addChild(e.target.content);
			if(onComplete)onComplete(copy());
			destroy();
		}
		private function removeByteListen():void{
			load.contentLoaderInfo.removeEventListener(Event.COMPLETE,byteloaded);
			load=null;
		}
	}
}